<?php $this->headLink()
        ->appendStylesheet($this->layout()->staticBaseUrl . 'application/modules/Filter/externals/styles/style_support_tabs.css');
?>

<h3><?php echo $this->translate('My filters'); ?></h3>
<br>
<div class="create_filter">
	<h3>
		<a href="<?php echo $this->url(array('action' => 'create', 'format' => 'smoothbox'),'filter_general', true); ?>" class="smoothbox"><?php echo $this->translate('Create new filter'); ?></a>
	</h3>
</div>

<div class="manage_filter">
    <div class="tabs_alt tabs_parent">
        <ul id="main_tabs">
            <?php foreach ($this->filter_types as $type) { ?>
            <li class="<?php if($type->type_name == $this->type_param) { echo('active'); } ?>">
                <a class="tab" href="<?php echo $this->url(array('action' => 'manage', 'filter_type' => $type->type_name),'filter_general', true); ?>" data-tab="critera-<?php echo $type->type_name; ?>-tab">
                    <?php echo $type->title; ?>
                </a>
            </li>
            <?php } ?>
        </ul>
    </div>
     
    <div id="home">
<?php if (!empty($this->title_struc)) { ?>
    <?php foreach ($this->title_struc as $type => $values) { ?>

        <div id="critera-<?php echo $type; ?>-tab" class="cus-tabContent <?php if($type == $this->type_param) { echo('active'); } ?>">
        <?php if (!empty($this->filters)) { ?>
            <table width="100%">
                <thead>
                  <tr>
                    <th class="table-menu" align="left" width="5%">
                        <?php echo $this->translate("ID"); ?>  
                    </th>
                    <th class="table-menu" align="left" width="15%">
                        <?php echo $this->translate("Filter name"); ?>  
                    </th>
                    <th class="table-menu" align="left" width="10%">
                        <?php echo $this->translate("Type"); ?>  
                    </th>
                <?php foreach ($values as $value) { ?>
                    <th class="table-menu" align="left" width="10%">
                        <?php echo $value; ?>
                    </th>
                <?php } ?>
                     
                    <th class="table-menu" align="left" width="10%">
                        <?php echo $this->translate("Options"); ?>
                    </th> 
                  </tr>
                </thead>
                <tbody>
            <?php foreach ($this->filters as $filter) { ?>           
                <?php if ($filter['filter_type'] == $type) { ?>    
                    <tr>
                        <td class="table_content" align="left"><?php echo $filter['filter_id']; ?></td>
                        <td class="table_content" align="left"><?php echo $filter['filter_title']; ?></td>
                        <td class="table_content" align="left"><?php echo $filter['filter_type_title']; ?></td>
                    
                    <?php foreach ($values as $criterianame_eltype => $value) { 
                            $criterianame_eltype = explode('-', $criterianame_eltype);
                            if ($criterianame_eltype[1] !== 'calendar') {
                                echo '<td class="table_content" align="left">'.$filter[$criterianame_eltype[0]].'</td>';
                            } else { 
                                $val_date = new Zend_Date(strtotime($filter[$criterianame_eltype[0]]));
                                $tz = $this->viewer()->timezone;
                                $val_date->setTimezone($tz);
                                echo '<td class="table_content" align="left">'.$this->locale()->toTime($val_date).' '.$this->locale()->toDate($val_date).'</td>';
                            }
                        }
                    ?>
                        
                        <td align="left">
                            <?php echo $this->htmlLink(array('action' => 'edit', 'route' => 'filter_general', 'id' => $filter['filter_id'], 'format' => 'smoothbox'), 'Edit', array('class' => 'smoothbox', 'title' => $this->translate('Edit'))); ?>    	

                            <?php echo $this->translate('|'); ?>

                            <?php echo $this->htmlLink(array('action' => 'delete', 'route' => 'filter_general', 'id' => $filter['filter_id'], 'format' => 'smoothbox'), 'Delete', array('class' => 'smoothbox', 'title' => $this->translate('Delete'))); ?>    	
                        </td>              
                    </tr>
                <?php } ?> 
            <?php } ?> 
                </tbody>
            </table>
            <br />
        <?php echo $this->paginationControl($this->filters); ?>
        <?php } else { ?>
            <span>
                    <?php echo '<div class="tip"><span>No filters were found. Click <a href="'. $this->url(array('action' => 'create', 'format' => 'smoothbox'), 'filter_general', true) .'" class="smoothbox">here</a> to add new filter.</span></div>'; ?>
            </span>
        <?php } ?>
        </div>
    <?php } ?>
<?php } ?>
    </div>
</div>
<style type="text/css">
.table_menu {
	padding-bottom: 10px;
	border-bottom: solid 1px #CCC;
}
.table_content {
	padding: 10px 15px 0px 0px;
}
</style>